/**
 * 
 */
package com.meetingshow.privilege.service.util;

import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.BaseQueryParasBuilder;
import com.meetingshow.privilege.service.model.UserQueryParas;

/**
 * @author louyi
 *
 */
public class UserQueryParasBuilder extends BaseQueryParasBuilder {
    public static QueryStruct userQueryBuilder(QueryStruct queryStruct, UserQueryParas userQueryParas) throws Exception {
        builderInit(userQueryParas, queryStruct);
        
        Map<String, Object> exactMap = queryStruct.getExactMap();
        Map<String, String> mistinessMap = queryStruct.getMistinessMap();
        
        if (StringUtils.isNotBlank(userQueryParas.getUserId_e())) {
            exactMap.put(UserServiceParas.USERPO_USER_ID, new Integer(userQueryParas.getUserId_e()));
        }
        
        if (StringUtils.isNotBlank(userQueryParas.getUserName_e())) {
            exactMap.put(UserServiceParas.USERPO_USER_NAME, userQueryParas.getUserName_e());
        }
        
        if (StringUtils.isNotBlank(userQueryParas.getUserName())) {
            mistinessMap.put("upper(" + UserServiceParas.USERPO_USER_NAME + ")", userQueryParas.getUserName().toUpperCase());
        }
        
        if (StringUtils.isNotBlank(userQueryParas.getPassword_e())) {
            exactMap.put(UserServiceParas.USERPO_PASSWORD, userQueryParas.getPassword_e());
        }
        
        if (StringUtils.isNotBlank(userQueryParas.getEmail_e())) {
            exactMap.put(UserServiceParas.USERPO_EMAIL, userQueryParas.getEmail_e());
        }
        
        if (StringUtils.isNotBlank(userQueryParas.getEmail())) {
            mistinessMap.put("upper(" + UserServiceParas.USERPO_EMAIL + ")", userQueryParas.getEmail().toUpperCase());
        }
        
        pageBuilder(queryStruct, userQueryParas);
        
        return queryStruct;
    }
}
